package cn.kgc.crowd1040.fundingadmin.service.impl;

import cn.kgc.crowd1040.fundingadmin.pojo.Role;
import cn.kgc.crowd1040.fundingadmin.mapper.RoleMapper;
import cn.kgc.crowd1040.fundingadmin.service.RoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gl
 * @since 2022-10-25
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Resource
    RoleMapper roleMapper;

    @Override
    public List<Role> getAssignedRoleList(Integer adminId) {
        return roleMapper.getAssignedRoleList(adminId);
    }

    @Override
    public List<Role> getUnAssignedRoleList(Integer adminId) {
        return roleMapper.getUnAssignedRoleList(adminId);
    }

    @Override
    @Transactional
    public void updateRelationship(Integer adminId, List<Integer> roleIdList) {
        //删除旧的
        roleMapper.deletAdminRelationRole(adminId);
        //添加新的
        roleMapper.insertAdminRelationRole(adminId,roleIdList);
    }
}
